package com.pronhub.cloud.shop.msg;

import com.pronhub.shop.cloud.CodeMSg;

import java.text.MessageFormat;

public class MemberServerCodeMsg extends CodeMSg {
    private MemberServerCodeMsg(Integer code,String msg){
        super(code,msg);
    }
    public static final MemberServerCodeMsg OP_ERROR = new MemberServerCodeMsg(500101,"非法操作");
    public static final MemberServerCodeMsg LOGIN_ERROR = new MemberServerCodeMsg(500102, "账号或者密码错误");

    public static final MemberServerCodeMsg LOGIN_ERROR_NULLUSER = new MemberServerCodeMsg(500105,"用户不存在");
    //2020-2-5 10:40:25
    public static final MemberServerCodeMsg PARAM_ERROR = new MemberServerCodeMsg(500103,"参数校验:{0}");
    //和这个工具类相当于替换掉我们的消息 {0}这个是占位符 利用工具类替换原来的占位符
    public MemberServerCodeMsg fillArgs(Object... args){
        //这里的这个This就是选择的是哪个CodeMsg
        MemberServerCodeMsg codeMsg = new MemberServerCodeMsg(this.getCode(),this.getMsg());
        codeMsg.setMsg(MessageFormat.format(codeMsg.getMsg(),args));

        return codeMsg;
    }
}
